package com.pls.handlers;

import java.util.ArrayList;

import com.plsContracts.dataContracts.GetProjectsRequest;
import com.plsContracts.dataContracts.GetProjectsResponse;
import com.plsContracts.dataContracts.SearchEmployeeRequest;
import com.plsContracts.dataContracts.SearchEmployeeResponse;
import com.plsDTO.validation.ValidationError;
import com.plsData.data.EmployeeData;
import com.plsData.data.ProjectData;

public class GetProjectsHandler extends
		RequestHandler<GetProjectsResponse, GetProjectsRequest> {

	public GetProjectsHandler(Class<GetProjectsResponse> tResponse) {
		super(tResponse);
		// TODO Auto-generated constructor stub
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.pls.handlers.RequestHandler#process(com.plsContracts.data.Request)
	 */
	protected ArrayList<ValidationError> validate(GetProjectsRequest request) {
		ArrayList<ValidationError> errors = new ArrayList<ValidationError>();
		ValidationError valError;
		if (request == null) {
			valError = new ValidationError();
			valError.setMessage("Request is null.");
			valError.setName("NullRequest");
			errors.add(valError);
			return errors;
		}
		if (request.getEmployeeId() == 0) {
			valError = new ValidationError();
			valError.setMessage("Employee Id cannot be null.");
			valError.setName("InvalidInput");
			errors.add(valError);
		}

		return errors;
	}

	protected GetProjectsResponse process(GetProjectsRequest request) {
		GetProjectsResponse response = new GetProjectsResponse();

		ProjectData projData = new ProjectData();
		response.setProjectList(projData.getProjectsByEmployeeId(request
				.getEmployeeId()));
		return response;

	}
	
	

}
